package com.codbking.calendar.exaple;

import android.app.Application;
import android.database.sqlite.SQLiteDatabase;

import com.codbking.calendar.exaple.greendao.gen.DaoMaster;
import com.codbking.calendar.exaple.greendao.gen.DaoSession;

/**
 * Created by SensYang on 2019/06/12 22:24
 */

public class CEApplication extends Application {

    private DaoMaster.DevOpenHelper mHelper;
    private SQLiteDatabase db;
    private DaoMaster mDaoMaster;
    private DaoSession mDaoSession;
    public static CEApplication instance;

    public static CEApplication getInstance() {
        return instance;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;

        //初始化数据库
        setDatabase();
    }

    private void setDatabase() {
        mHelper = new DaoMaster.DevOpenHelper(this, "notes_db", null);
        db = mHelper.getWritableDatabase();
        mDaoMaster = new DaoMaster(db);
        mDaoSession = mDaoMaster.newSession();
    }
}
